#pragma once

#include "../umlmodel_global.h"

#include <memory>
#include <vector>

#include "NamedElement.h"

using std::make_shared;
using std::shared_ptr;
using std::vector;

namespace uml {
class Event;
class Port;

/// <summary>
/// Trigger
/// A Trigger specifies a specific point  at which an Event occurrence may trigger
/// an effect in a Behavior. A Trigger may be qualified by the Port on which the
/// Event occurred.
/// </summary>
class UMLMODEL_EXPORT Trigger : public NamedElement {

public: // Constructors and destructors
    explicit Trigger(const QString& umlType="uml::Trigger");

public: // JsonSerializable override
    void fromJson(const QJsonObject& json, QStringList& errorList) override;
    void toJson(QJsonObject& json) override;

public: // Properties
    /// <summary>
    /// event getter
    /// The Event that detected by the Trigger.
    /// </summary>
    shared_ptr<Event> event() const;

    /// <summary>
    /// event setter
    /// The Event that detected by the Trigger.
    /// </summary>
    void setEvent(shared_ptr<Event> value);

    /// <summary>
    /// ports getter
    /// A optional Port of through which the given effect is detected.
    /// </summary>
    vector<shared_ptr<Port>>& ports();

private: // Fields
    /// <summary>
    /// event
    /// The Event that detected by the Trigger.
    /// </summary>
    shared_ptr<Event> event_;

    /// <summary>
    /// ports
    /// A optional Port of through which the given effect is detected.
    /// </summary>
    vector<shared_ptr<Port>> ports_;

};

} // namespace uml
